<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>修改用户信息</title>
    <link rel="stylesheet" th:href="@{/layui/layui/css/layui.css}">
</head>
<body>
<br />
<div class="layui-form-item">
    <div class="layui-inline">
        <label class="layui-form-label">用户容量(M)</label>
        <div class="layui-input-inline">
            <input id="memory"  style="width: 250px;" th:value="${memory}" type="tel" name="groupname" lay-verify="required|phone" autocomplete="off" class="layui-input">
            <input th:value="${uid}" type="hidden"  id="uid"/>
        </div>
    </div>
    <form class="layui-form">
        <label class="layui-form-label">所属群组</label>
        <div class="layui-input-inline" style="width: 250px;">
            <select id="group"  name="quiz1" style="max-height: 360px;">
            </select>
        </div>
    </form>
    <br/><br/><button type="button" style="float: right;margin-right: 65px;" class="layui-btn layui-btn-radius layui-btn-normal" onclick="updateuser()">保 存</button>
</div>
<script th:src="@{/static/js/jquery-3.4.1.min.js}" type="text/javascript"></script>
<script th:src="@{/layui/layui/layui.js}"></script>
<script>
    var groupid = [[${groupid!=null?groupid:0}]];
    var id = [[${id}]];
    var uid = $('#uid').val();
    var form = null;
    layui.use(['form','table','layer'], function(){
        table = layui.table;
        var layer = layui.layer;
         form = layui.form;
        $.ajax({
            type: "POST",
            url: "/admin/root/getgrouplist",
            dataType: "json",
            success: function (data) {
                var body = '';
                for(var i=0;i<data.length;i++){
                    body+='<option value="'+data[i].id+'">&nbsp;'+data[i].groupname+'</option>';
                }
                $('#group').append(body);
                $('#group').val(groupid);
                form.render('select');
            }
        });
        form.on('select', function(data){
            groupid = data.value;
        });
    });
function updateuser() {
    layer.msg('加载中', {
        icon: 16
        ,shade: 0.01
    });
    var memory = $('#memory').val();
    $.ajax({
        type: "POST",
        url: "/admin/root/updateuser",
        data: {memory:memory,groupid:groupid,uid:uid,id:id},
        dataType: "json",
        success: function (data) {
            if (data > 0) {
                table.reload('datas');//重新获取表数据
                layer.msg('修改成功', {icon: 1});
            }else{
                layer.msg('修改失败', {icon: 2});
            }
        }
    });
    layer.closeAll();
}
</script>
</body>
</html>